package com.levi.juc.singlemodel;

/**
 * 饿汉式，一上来就加载对象
 * 饿汉式的问题:
 * 容易导致内存浪费
 */
public class HungryModel {
    //加入前面有占有很大内存的变量，就会先开批出来这么多内存而没有使用，就会导致内存浪费
    private byte[] a = new byte[1204 * 1024];
    private byte[] b = new byte[1204 * 1024];
    private byte[] c = new byte[1204 * 1024];
    private byte[] d = new byte[1204 * 1024];

    private HungryModel() {

    }

    private static final HungryModel hungryModel = new HungryModel();

    public static HungryModel getInstance() {
        return hungryModel;
    }
}
